package com.rainy.cloud.core.exception.factory;

import com.rainy.cloud.core.exception.definition.*;
import com.rainy.cloud.entity.ResultCode;

/**
 * 异常工厂
 */
public class ExceptionFactory {

    /**
     * 未登录异常
     * @param message
     * @return
     */
    public static NoLoginException newInstanceNoLoginException(String message) {
        return new NoLoginException(ResultCode.NOLOGIN_EXCEPTION, message);
    }

    /**
     * 验证异常
     * @param message
     * @return
     */
    public static ValidateException newInstanceValidateException(String message) {
        return new ValidateException(ResultCode.VALIDATE_EXCEPTION, message);
    }

    /**
     * 业务异常
     * @param message
     * @return
     */
    public static BizException newInstanceBizException(String message) {
        return new BizException(ResultCode.BIZ_EXCEPTION, message);
    }

    /**
     * 服务异常
     * @param message
     * @return
     */
    public static ServerException newInstanceServerException(String message) {
        return new ServerException(ResultCode.SERVER_EXCEPTION, message);
    }

    /**
     * 应用异常
     * @param message
     * @return
     */
    public static ApplicationException newInstanceApplicationException(String message) {
        return new ApplicationException(ResultCode.APPLICATION_EXCEPTION, message);
    }

    /**
     * 未知异常
     * @param message
     * @return
     */
    public static UnknownException newInstanceUnknownException(String message) {
        return new UnknownException(ResultCode.UNKNOWN_EXCEPTION, message);
    }

    /**
     * 自定义异常
     * @param code
     * @param message
     * @return
     */
    public static BaseException newInstance(String code, String message) {
        return new BaseException(code, message);
    }

}
